import 'package:flutter/material.dart';
import 'package:fluwx_no_pay/fluwx_no_pay.dart';
import 'package:get/get.dart';
import 'package:industry_net/base/common/fluwx_util.dart';
import 'package:industry_net/base/common/share/model.dart';
import 'package:industry_net/base/common/util.dart';
import 'package:industry_net/base/component/component.dart';

showShare() {
  if (Get.context == null) {
    return;
  }
  List<ShareModel> items = [
    ShareModel(title: '微信', icon: 'icon_wechat.png'.imgPathMe),
    ShareModel(title: '朋友圈', icon: 'icon_wechat.png'.imgPathMe),
    ShareModel(title: '微博', icon: 'icon_wechat.png'.imgPathMe),
  ];
  showModalBottomSheet(
      context: Get.context!,
      backgroundColor: ColorsUtil.bg,
      constraints: BoxConstraints.expand(
          height: 20.r + 70.r + 10.r + buttonHeight + SizeFit.safeBottom),
      builder: (context) {
        return Container(
          padding: EdgeInsets.only(top: 20.r),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              SizedBox(
                width: double.infinity,
                child: Wrap(
                  alignment: WrapAlignment.spaceEvenly,
                  children: items
                      .asMap()
                      .map(
                        (key, value) => MapEntry(
                          key,
                          MenuItemView(
                              onTap: () {
                                shareToWx();
                              },
                              icon: loadImage(
                                  url: value.icon, width: 35.r, height: 35.r),
                              title: Text(
                                value.title,
                                style: pfMediumStyle(
                                    color: ColorsUtil.title, fontSize: font15),
                              )),
                        ),
                      )
                      .values
                      .toList(),
                ),
              ),
              SizedBox(
                height: 10.r,
              ),
              InkWell(
                onTap: Get.back,
                child: Container(
                  padding: EdgeInsets.only(bottom: SizeFit.safeBottom),
                  alignment: Alignment.center,
                  width: double.infinity,
                  height: buttonHeight + SizeFit.safeBottom,
                  color: Colors.white,
                  child: Text(
                    '取消',
                    style: pfMediumStyle(
                        color: ColorsUtil.title, fontSize: font14),
                  ),
                ),
              )
            ],
          ),
        );
      });
}

void shareToWx() {
  var md = WeChatShareWebPageModel(
    'https://www.baidu.com',
    title: '分享标题',
    thumbnail: WeChatImage.asset('menu_icon_pear.png'.imgPathHome),
  );
  WXUtil().share(md);
}
